<template>
  <div class="com-box">
    <div class="common-title">
      中心核对
    </div>

    <div>
      <div class="flex justify-end">
        <el-button size="primary" @click="goExport()" style="width:100px;">导出</el-button>
      </div>

      <div class="title">
        日间手术病房患者检查/检验项目核查单
      </div>

      <div class="table">
        <el-table :data="state.tableData" border style="width: 100%" >
          <el-table-column  label="项目" align="center" >
            <template #default="scope">
							{{ scope.row.checkItem.text }}
						</template>
          </el-table-column>
          <el-table-column  label="办公班" align="center" >
            <template #default="scope">
              <div v-if="scope.row.checkItem.text !='签名'">
                <el-icon v-if="scope.row.office" color="#3081F4" size="18px"><Select /></el-icon>
                <div v-else>-</div>
              </div>

              <div v-else>
                <span v-if="scope.row.officeCheckSign.length == 0">-</span>
                <el-image v-for="(item,index) in scope.row.officeCheckSign" :key="index" :src="item.sign"  alt="" fit="cover"/>
              </div>
						</template>
          </el-table-column>
          <el-table-column  label="夜班" align="center" >
            <template #default="scope">
							 <div v-if="scope.row.checkItem.text !='签名'">
                <el-icon v-if="scope.row.night" color="#3081F4" size="18px"><Select /></el-icon>
                <div v-else>-</div>
              </div>
              
              <div v-else>
                <span v-if="scope.row.nightCheckSign.length == 0">-</span>
							  <el-image v-for="(item,index) in scope.row.nightCheckSign" :key="index" :src="item.sign"  alt="" fit="cover"/>
              </div>
						</template>
          </el-table-column>
          <el-table-column  label="责任班" align="center" >
            <template #default="scope">
              <div v-if="scope.row.checkItem.text !='签名'">
                <el-icon v-if="scope.row.duty" color="#3081F4" size="18px"><Select /></el-icon>
                <div v-else>-</div>
              </div>
              
              <div v-else>
                <span v-if="scope.row.dutyCheckSign.length == 0">-</span>
							  <el-image v-for="(item,index) in scope.row.dutyCheckSign" :key="index" :src="item.sign"  alt="" fit="cover"/>
              </div>
						</template>
          </el-table-column>
        
        </el-table>
      </div>
    </div>

    <!-- <img :src="zxhd" alt=""> -->
  </div>
</template>

<script setup name="centerCheck">
import { Select } from '@element-plus/icons-vue'
import { getHost } from "/@/utils/getHost";
import { Session } from '/@/utils/storage';

const props = defineProps({
  datas: {
    type: Object,
    default: () => { },
  },
});

const state = reactive({
  tableData: [
    
  ]
})

const route = useRoute();

// 页面加载时
onMounted(() => {
  console.log(props.datas)
  if(props.datas.centreCheck && props.datas.centreCheck.patientRecordCentreCheckItems){
    const newList = JSON.parse(JSON.stringify(props.datas.centreCheck.patientRecordCentreCheckItems))
    newList.push({
      checkItem:{
        text: '签名'
      },
      officeCheckSign: props.datas.centreCheck.officeCheckSign,
      nightCheckSign: props.datas.centreCheck.nightCheckSign,
      dutyCheckSign: props.datas.centreCheck.dutyCheckSign
    })
    state.tableData = newList
  }
});

const goExport = () => {
  const url =  getHost() + '/patient/export_centre_check' + '?prid=' + route.query.id + '&token=' + Session.get('token')
  const link = document.createElement('a')
  link.href = url
  link.setAttribute('download', '')
  document.body.appendChild(link)
  link.click()
  document.body.removeChild(link)
}

</script>

<style lang="scss" scoped>
.com-box {
  min-height: 620px;
}

.title {
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  margin: 20px 0;
}
</style>
